package com.service.activemq;

import com.common.config.ApplicationConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Service;
/**
 * @className: MessageSenderService
 * @description: TODO 创建消息发送者
 * @author: zql
 * @date: 2023/10/14 0:08
 * @Company: Copyright© [日期] by [作者或个人]
 **/
@Service
@Slf4j
public class MessageSenderService {
    private final JmsTemplate  jmsTemplate;

    public MessageSenderService(JmsTemplate  jmsTemplate) {
        this.jmsTemplate = jmsTemplate;
    }
    /**
     * 消息发送
     * @param message
     */
    public void sendMessage(String message) {
        log.info("Destination：{}，activemq消息发送内容：{}",ApplicationConfig.getDestination(),message);
        jmsTemplate.convertAndSend(ApplicationConfig.getDestination(), message);
    }

}
